package com.twu.biblioteca;

import com.twu.biblioteca.Models.Book;
import com.twu.biblioteca.Models.Movie;

import java.util.*;

/**
 * User: haruo
 * Date: 5/17/13
 */
public class LibraryCollection {
    private HashMap<String, Book> books;
    private HashMap<String, Movie> movies;

    public LibraryCollection(HashMap<String, Book> bookList, HashMap<String, Movie> movieList) {
        this.books = bookList;
        this.movies = movieList;
    }

    public Book findBook(String bookISBN) {
        for (Book book: this.books.values())
        {
            if (book.getISBN().equals(bookISBN)) {
                return book;
            }
        }
        return null;
    }

    public String getBookList() {
        String booksList = "";
        booksList += "ISBN\t\tTitle\t\tAuthor\t\tQuantity\n";
        for (Book book : this.books.values())
        {
            booksList += book.toString();
        }
        return booksList;
    }

    public String getMovieList() {
        String movieList = "";
        movieList += "Title\tYear\tDirector\tRating\n";
        for (Movie movie: this.movies.values())
        {
            movieList += movie.toString();
        }
        return movieList;
    }
}
